package com.hyzh.latte.vehicle.example;

import org.apache.hugegraph.driver.HugeClient;
import org.apache.hugegraph.structure.graph.Edge;
import org.apache.hugegraph.structure.graph.Vertex;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author songkui
 * @since 2024/3/19 16:14
 */
public class HugeGraphClientManager {

    // key : parkCode;  v: client;
    private static Map<String, HugeClient> clientMap = new HashMap<>();

    public static void initClientMap(List<GraphProperties.Graph> graphs){
        for (GraphProperties.Graph graph : graphs){
            clientMap.put(graph.getParkCode(), HugeClient.builder(graph.getGraphUrl(), graph.getGraphName()).build());
        }
    }

    public static List<Vertex> listAllVertex(String parkId){
        return clientMap.get(parkId).graph().listVertices();
    }

    public static List<Edge> listAllEdge(String parkId){
        return clientMap.get(parkId).graph().listEdges();
    }


}
